/*********************************************************************
**	File: Defines.hpp
**	Author: Asteroth
**	Date: Apr 26, 2009
*********************************************************************/

#ifndef __DEFINES_HPP__
#define __DEFINES_HPP__
#pragma once

#if (defined(linux) || defined(__linux) || defined(__linux__)) && !defined(LINUX)
	#define LINUX
#elif (defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)) && !defined(BSD)
	#define BSD
#elif (defined(sun) || defined(__sun)) && !defined(SOLARIS)
	#define SOLARIS
#elif defined(__CYGWIN__) && !defined(CYGWIN)
	#define CYGWIN
#elif (defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(_MSC_VER) || defined(__WATCOMC__) || defined(__MINGW32__) || defined(_WIN32_WCE)) && !defined(WINDOWS)
	#define WINDOWS
#elif (defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)) && !defined(MACOS)
	#define MACOS
#elif (defined(unix) || defined(__unix) || defined(_XOPEN_SOURCE) || defined(_POSIX_SOURCE)) && defined(BOOST_HAS_PTHREADS && !defined(BOOST_THREAD_POSIX) && !defined(POSIX)
	#define POSIX
#else
	#if !defined(LINUX) && !defined(WINDOWS) && !defined(SOLARIS) && !defined(BSD) && !defined(CYGWIN) && !defined(MACOS) && !defined(POSIX)
		#error "Can't determine platform."
	#endif
#endif

// void zen_sleep(milliseconds)
#ifdef LINUX
    #define zen_sleep(milli) usleep(milli)
#else
    #ifdef WINDOWS
        #define zen_sleep(milli) Sleep(milli)
    #endif
#endif

// u32 zen_clock()
#if defined(LINUX)
	#define zen_clock() (clock()/1000)
#elif defined(WINDOWS)
	#define zen_clock() clock()
#endif

#include <boost/lexical_cast.hpp>
#define cast(type, arg) boost::lexical_cast<type>(arg)
#define to_str(arg) cast(std::string, arg)
#define to_int(arg) cast(int, arg)
#define to_uint(arg) cast(unsigned int, arg)
#define to_float(arg) cast(float, arg)
#define to_double(arg) cast(double,arg)

#endif
